/**
 * 
 */
package com.sjzs.web.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * 
 * @description: 获取配置文件config.properties
 */
public class ConfigUtil {

	private static ConfigUtil instance = new ConfigUtil();

	private Properties pro = new Properties();

	private static final Logger LOGGER = Logger.getLogger(ConfigUtil.class);
	
	/**
	 * 
	 * @return ConfigUtil
	 * @description:
	 */
	public static ConfigUtil getInstance() {
		return instance;
	}

	/**
	 * 构造函数
	 */
	private ConfigUtil() {
		loadConfig();
	}

	/**
	 * @description:
	 */
	private void loadConfig() {

		try {
			ClassLoader loader = getClass().getClassLoader();
			InputStream in = loader.getResourceAsStream("config.properties");
			pro.load(in);
		} catch (IOException e) {
			LOGGER.error(e);
		}
	}

	/**
	 * 
	 * @param key 属性名称
	 * @return String
	 * @description: 获取配置文件属性
	 */
	public String getProperties(String key) {
		return pro.getProperty(key);
	}

}
